<?php
namespace Admin\Controller;
use Think\Controller;
class ListController extends Controller{
	public function index(){
	    $cate=new Message();
	    // select * from mb_liuyan
	    $list=M('liuyan')->select();
	    //引用无限极分类类库
	    $this->liuyan=Message::unlimitedForLevel($list,'&nbsp;&nbsp;----');
	    //显示前台
	    $this->display();
	}
	public function delete(){
		//选择ID
	    $id=I('id');
	    //M是选择表
	    //delete from mb_liuyan where(id=$id);
        if(M('liuyan')->delete($id)){
        	$this->success('留言删除成功',U('List/index'));
        }else{
        	$this->error('留言删除失败');
        }
	}
	public function answer(){
	    $db=M('liuyan');
        $data['name']='admin';
        $data['content']=I('content');
        $data['time']=time();
        $data['aid']=I('aid');
        //p($data);die;

        //create 创建数据对象
        $db->create($data);	
        //add：insert into mb_liuyan()values('aid','content','time'...);
        if($db->add()){
        	$this->success('留言回复成功',U('List/index'));
        }else{
        	$this->error('留言回复失败');
        }
	}
	public function addList(){
	    // $this->aid=I('id');
	    //显示界面
	    $this->display();
	}

}
?>